<div id="offline-check-in-view">
  <div class="pageheader">
    <h2><i class="fa fa-home"></i>线下入住{{contractData?('(合同号：'+contractData.uuid+')'):''}}</h2>
    <div class="al-header-right">
      <button type="button" class="btn btn-warning" ng-click="backToEntrance()">返回</button>
    </div>
  </div>
  <div class="page">
    <ng-form name="contractForm" class="form-horizontal">
      <div class="form-group">
        <h4 class="text-center">房间信息</h4>
      </div>
      <div class="form-group">
        <label class="control-label col-sm-2 col-sm-offset-1">公寓</label>
        <div class="col-sm-3">
          <select ng-model="contractNew.apartmentId" class="form-control"
                  ng-change="loadBuilding()" ng-readonly="contractNew.created"
                  ng-options="option.id as option.name for option in apartmentList"></select>
        </div>
        <label class="control-label col-sm-2">楼栋</label>
        <div class="col-sm-3">
          <select ng-model="contractNew.buildingId" ng-readonly="contractNew.created"
                  class="form-control" ng-change="loadFloor()"
                  ng-options="option.id as option.name for option in buildingList"></select>
        </div>
      </div>
      <div class="form-group">
        <label class="control-label col-sm-2 col-sm-offset-1">楼层</label>
        <div class="col-sm-3">
          <select ng-model="contractNew.floor" ng-readonly="contractNew.created || contractNew.buildingId==undefined"
                  class="form-control" ng-change="loadHouse()"
                  ng-options="option.id as option.name for option in floorList"></select>
        </div>
        <label class="control-label col-sm-2">房间号</label>
        <div class="col-sm-3">
          <select ng-model="contractNew.houseId" ng-readonly="contractNew.created || contractNew.floor==undefined"
                  class="form-control" ng-change="pickHouse()"
                  ng-options="option.id as option.houseNo for option in houseList"></select>
        </div>
      </div>
      <div class="form-group">
        <label class="control-label col-sm-2 col-sm-offset-1">租房方式</label>
        <div class="col-sm-3">
          <select ng-model="contractNew.payWay" ng-readonly="contractNew.created || houseInfo==undefined"
                  class="form-control"
                  ng-options="option.value as option.name for option in payWayList"></select>
        </div>
        <label class="control-label col-sm-2">租期</label>
        <div class="col-sm-3">
          <select ng-model="contractNew.lease" ng-readonly="contractNew.created || houseInfo==undefined"
                  class="form-control"
                  ng-options="option.value as option.name for option in leaseList"></select>
        </div>
      </div>
      <div class="form-group">
        <label class="control-label col-sm-2 col-sm-offset-1">月租金</label>
        <div class="col-sm-3">
          <div class="form-control info-text">{{houseInfo==undefined?'--':houseInfo.salePrice}}</div>
        </div>
        <label class="control-label col-sm-2">押金</label>
        <div class="col-sm-3">
          <div class="form-control info-text">{{houseInfo==undefined?'--':houseInfo.depositPrice}}</div>
        </div>
      </div>
      <div class="form-group">
        <label class="control-label col-sm-2 col-sm-offset-1">合同开始日期<span class="attr-need">*</span></label>
        <div class="col-sm-3">
          <div class="input-group">
            <input class="form-control" type="text" uib-datepicker-popup="yyyy-MM-dd" readonly
                   ng-model="contractNew.leaseStart" is-open="enterStart" maxlength="10"
                   close-text="关闭" current-text="今天" clear-text="清空" required
                   placeholder=""/>
            <span class="input-group-btn">
                <button type="button" class="btn btn-default" ng-click="enterStart=true">
                  <i class="glyphicon glyphicon-calendar"></i>
                </button>
              </span>
          </div>
        </div>
        <!--<label class="control-label col-sm-2">合同签署时间</label>-->
        <!--<div class="col-sm-3">-->
          <!--<input type="text" class="form-control" ng-model="contractNew.signTime">-->
        <!--</div>-->
      </div>
    </ng-form>
    <ng-form name="personForm" class="form-horizontal">
      <div class="form-group">
        <h4 class="text-center">租客信息</h4>
      </div>
      <div class="form-group">
        <div class="col-sm-6">
          <div class="form-group">
            <label class="control-label col-sm-4 col-sm-offset-2">租客名称</label>
            <div class="col-sm-6">
              <input type="text" class="form-control" ng-readonly="contractNew.created"
                     ng-model="person.customerName">
            </div>
          </div>
          <div class="form-group">
            <label class="control-label col-sm-4 col-sm-offset-2">租客手机号</label>
            <div class="col-sm-6">
              <input type="text" class="form-control" ng-readonly="contractNew.created"
                     ng-model="person.customerPhone">
            </div>
          </div>
          <div class="form-group">
            <label class="control-label col-sm-4 col-sm-offset-2">身份证</label>
            <div class="col-sm-6">
              <input type="text" class="form-control" ng-readonly="contractNew.created"
                     ng-model="person.customerCard">
            </div>
          </div>
          <div class="form-group">
            <label class="control-label col-sm-4 col-sm-offset-2">性别</label>
            <div class="col-sm-6">
              <nobr>
                <label class="ui-radio" ng-repeat="option in sexList">
                  <input name="status" ng-value="option.value" ng-readonly="contractNew.created"
                         type="radio" ng-model="person.sex">
                  <span>{{option.name}}</span>
                </label>
              </nobr>
            </div>
          </div>
          <div class="form-group">
            <label class="control-label col-sm-4 col-sm-offset-2">住客人数</label>
            <div class="col-sm-6">
              <div class="input-group">
                <input type="number" class="form-control" readonly ng-model="cotenant.length" maxlength="4">
                <span class="input-group-addon" ng-click="offlineCotenant()">{{contractData?'查看':'编辑'}}</span>
              </div>
            </div>
          </div>
        </div>
        <div class="col-sm-6">
          <div class="form-group" style="margin-bottom: 10px;">
            <label class="control-label col-sm-4 ">身份证正面</label>
            <div class="col-sm-6 id-card-container">
              <img ng-src="{{person.idcardFront?person.idcardFront:'images/id_card_front.jpg'}}"
                   ng-click="uploadIDCFront()">
              <input id="off-idcard-front" style="display: none" type="file" >
            </div>
          </div>
          <div class="form-group">
            <label class="control-label col-sm-4">身份证反面</label>
            <div class="col-sm-6 id-card-container">
              <img ng-src="{{person.idcardBack?person.idcardBack:'images/id_card_back.jpg'}}"
                   ng-click="uploadIDCBack()">
              <input id="off-idcard-back" style="display: none" type="file" >
            </div>
          </div>
        </div>

      </div>
      <div class="form-group">
        <div class="col-sm-4"></div>
        <div class="col-sm-4" style="text-align:center;">
          <button class="btn btn-primary" ng-if="!contractNew.created"
                  ng-disabled="contractNew.creating || contractForm.$invalid || personForm.$invalid"
                  ng-click="createContract()">生成合同</button></div>
          <button class="btn btn-warning" ng-if="contractNew.created"
                  ng-click="printContract()">合同打印</button>
        <div class="col-sm-4"></div>
      </div>
    </ng-form>
    <ng-form class="form-horizontal" ng-if="contractNew.created">
      <div class="form-group">
        <h4 class="text-center">线下收款</h4>
      </div>
      <div class="form-group">
        <label class="control-label col-sm-2 col-sm-offset-1">租金总计</label>
        <div class="col-sm-3">
          <div class="form-control info-text">{{contractData.money-contractData.deposit}}</div>
        </div>
        <label class="control-label col-sm-2">押金</label>
        <div class="col-sm-3">
          <div class="form-control info-text">{{contractData.depositPrice}}</div>
        </div>
      </div>
      <div class="form-group">
        <label class="control-label col-sm-2 col-sm-offset-1">应收金额</label>
        <div class="col-sm-3">
          <div class="form-control info-text">{{contractData.payMoney}}</div>
        </div>
        <label class="control-label col-sm-2">实收金额</label>
        <div class="col-sm-3">
          <div class="form-control info-text">{{contractData.payMoney}}</div>
        </div>
      </div>
      <div class="form-group">
        <label class="control-label col-sm-2 col-sm-offset-1">支付方式</label>
        <div class="col-sm-3">
          <select ng-model="pay.payType" class="form-control"
                  ng-options="option.id as option.name for option in offPayTypeList"></select>
        </div>
        <label class="control-label col-sm-2">操作员</label>
        <div class="col-sm-3">
          <div class="form-control info-text">客服二</div>
        </div>
      </div>
      <div class="form-group">
        <label class="control-label col-sm-2 col-sm-offset-1">收款备注</label>
        <div class="col-sm-6">
          <text-area class="form-control" cols="3" ng-model="pay.moneyDesc"></text-area>
        </div>
      </div>
      <div class="form-group">
        <div class="col-sm-3"></div>
        <div class="col-sm-3 text-center">
          <button class="btn btn-primary"
                  ng-confirm-click="{{'确认该客户已通过'+pay.payType|constantTransfer:offPayTypeList+'支付了'+contractData.payMoney+'元?'}}"
                  ng-click="confirmPay()">确认付款</button>
        </div>
        <div class="col-sm-3 text-center">
          <button class="btn btn-success" ng-if="contractData.status==2"
                  ng-click="offlineCheckIn()">快捷入住</button>
          <button class="btn btn-success" ng-if="contractData.status>2"
                  ng-click="offlineCheckIn()">快捷入住</button>
        </div>
        <div class="col-sm-3"></div>
      </div>
    </ng-form>
  </div>
</div>